import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Text {

    public static final String[] Rank = {"♥","♠","♣","♦"};
    public static Crad[] card;

    public static List<Crad> buyCard(){
        List<Crad> list = new ArrayList<>();
        for (int i = 0; i < Rank.length; i++) {
            for (int j = 1; j <= 13; j++) {
                Crad crad = new Crad(Rank[i],j );
                list.add(crad);
            }
        }
        return list;
    }

    public static void Shuffer(List<Crad> list){
        for (int i = list.size()-1; i > 0; i--) {
            Random random = new Random();
            int index = random.nextInt(i);

            Exchange(list,i,index);
        }
    }//洗牌操作
    public static void Exchange(List<Crad> List,int a,int b){
        Crad tem = List.get(a);
        List.set(a,List.get(b));
        List.set(b,tem);
    }//牌堆里的牌进行交换\

    public static void main(String[] args) {
        //牌堆初始化
        List<Crad> list = buyCard();
        System.out.println(list);
        //进行洗牌
        System.out.println("洗牌");
        Shuffer(list);
        System.out.println(list);
        System.out.println("取牌");
        //创建三个牌组
        List<Crad> A = new ArrayList<>();
        List<Crad> B = new ArrayList<>();
        List<Crad> C = new ArrayList<>();
        //创建一个包含三个牌组的大牌组，方便下面进行牌面的分配
        List<List<Crad>> AllCard = new ArrayList<>();
        AllCard.add(A);
        AllCard.add(B);
        AllCard.add(C);
        //三个牌组，每个牌组各拿五张牌
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 5; j++) {
                Crad crad = list.remove(0);
                AllCard.get(i).add(crad);
            }
        }
        //查看牌组
        System.out.println(AllCard.get(0));
        System.out.println(AllCard.get(1));
        System.out.println(AllCard.get(2));
    }
}
